import React, { Component } from 'react';
import {
    Text, Image, View, ToastAndroid, PixelRatio, ScrollView, TouchableOpacity
} from 'react-native';
import {NetworkUtils} from '../../src/util/ConsumerUtils';
export default class Test extends Component {

    constructor(props) {
        super(props);
        this.state = {
            avgInfo: {}
        }
    }

    async func() {
        let {success, result, avgInfo} = await NetworkUtils.ping('www.baidu.com');
        console.log(avgInfo['srate']);
        this.setState({
            result: result,
            avgInfo: avgInfo
        });
    }

    render() {
        return(
            <View>
                <Text style={{fontSize: 100}} onPress={this.func.bind(this)}>点击</Text>
                <Text>retult: {this.state.result}</Text>
                <Text>srate: {this.state.avgInfo['srate']}</Text>
                <Text>avg: {this.state.avgInfo['avg']} ms</Text>
            </View>
        );
    }
}